package com.glela.order.model.vo.order;

import java.util.Comparator;

import org.apache.commons.lang3.math.NumberUtils;

/**
 * 用户红包比较
 * @author zls
 *
 */
public class UserRedPacketComparator implements Comparator<UserRedPacketVo> {
	@Override

	public int compare(UserRedPacketVo o1, UserRedPacketVo o2) {
		int b = 0;
		if (o1.getEndTime() != null && o2.getEndTime() != null) {
			long a = o1.getEndTime().getTime() - o2.getEndTime().getTime();
			if (a > 0) {
				b = 1;
			} else if (a < 0) {
				b = -1;
			}
		}
		int c = o1.getOwnerId() - o2.getOwnerId();
		if (c > 0) {
			c = 1;
		} else if (c < 0) {
			c = -1;
		}
		return NumberUtils.compare(o1.getAmount(), o2.getAmount()) * 100 + b * 10 + c;
	}
}
